//
// Copyright (c) 2019-2023 BPer
//
#ifndef INCLUDE_BPERSTREAM_BPERSYNBUFFERMANAGER_H_
#define INCLUDE_BPERSTREAM_BPERSYNBUFFERMANAGER_H_
#include <bperstream/BPerSynBuffer.h>
#include <bperutil/sys/BPerVector.h>

bPer_vector_declare2(BPerSynBuffer)



typedef struct{
	bPer_thread_mutex_t playBufferMutex;
	BPerSynBuffer* playBuffer;
	BPerSynBufferVector2* playBuffers;
}BPerSynBufferSession;

typedef struct{
	BPerSynBufferSession* session;
	BPerSynBuffer* (*getSynBuffer)(BPerSynBufferSession* session,int puid);
	int (*getPlayBufferIndex)(BPerSynBufferSession* session,int puid);
	int32_t (*getAudioDatas)(BPerSynBufferSession* session, uint8_t* mixBuf,BPerFrame* pframe);
	int32_t (*addAudioBuffer)(BPerSynBufferSession* session,void* BPerAudioPlayBuffer,int32_t puid);
	void (*initAudioBuffer)(BPerSynBufferSession* session);
	void (*removeAllAudioBuffer)(BPerSynBufferSession* session);
	void (*removeAudioBuffer)(BPerSynBufferSession* session,int32_t puid);
}BPerSynBufferManager;

void bPer_create_synBufferManager(BPerSynBufferManager* man);
void bPer_destroy_synBufferManager(BPerSynBufferManager* man);
#endif /* INCLUDE_BPERSTREAM_BPERSYNBUFFERMANAGER_H_ */
